import { Component, OnInit } from '@angular/core';
import { NgbCarouselConfig } from '@ng-bootstrap/ng-bootstrap';
import { Slider } from '../../shared/models/slider-model';
import { ImageSlidersService } from '../../shared/services/image-sliders.service';
import { ActivatedRoute } from '@angular/router';

@Component({
  selector: 'app-home-slidlers',
  templateUrl: './images-slider.component.html',
  styleUrls: ['./images-slider.component.scss'],
  providers: [NgbCarouselConfig, ImageSlidersService]
})
export class ImagesSliderComponent implements OnInit {

  public slides: Array<Slider> = [];



  constructor(private config: NgbCarouselConfig,
    public imageSliderService: ImageSlidersService,
    public activeRoute: ActivatedRoute
  ) {

    config.interval = 5000;
    config.wrap = false;
    config.keyboard = false;
  }
  ngOnInit() {
    this.activeRoute.params.subscribe(
      params => {
        if (params) {
          this.GetimageSlidersList();
        }

      }
    );
  }

  public GetimageSlidersList() {
    this.imageSliderService.getRemoteSliders()
      .subscribe(
      datas => {
        this.slides = datas;
      },
      error => console.log(error)
      );
  }


}
